package com.manbearpig.todue;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
/**
 * This activity is launched so the user can create a new account
 * @author Andre Giron
 * @version 1.0
 */
public class CreateAccountActivity extends Activity {
    
	
	private Login_Manager lm;
	/** Called when the activity is first created. */
    @Override
	/**
	Method that runs when the app is launched for the first time
	@param savedInstanceState the state of the app the last time it was launched
	**/
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.create_account);
        lm = new Login_Manager();        
    }
    /**
     * OnClick handler for create account button
     * @param view
     */
    public void createAccount(View view)
    {
    	lm.setUsername(((EditText) findViewById(R.id.username_TextView)).getText().toString());
    	lm.setPassword(((EditText) findViewById(R.id.password_TextView)).getText().toString());
    	lm.setName(((EditText) findViewById(R.id.name_TextView)).getText().toString());
    	lm.setEmail(((EditText) findViewById(R.id.email_TextView)).getText().toString());
    	boolean success = lm.attemptCreate(this);
    	if(success)
    	{
    		finish();
    	}
    }
    
    /**
     * What to do when you cancel
     * @param view the requested view
     */
    public void onClick(View view) {
        finish();
    }
    
    public Login_Manager getLogin()
    {
    	return lm;
    }
}